package featureExtractors;

import pdi.OpenCvCaller;
import pdi.core.Image;

public class HOGFeatures extends AbstractFeatureExtraction {

	private int blockWidth;
	private int blockHeigth;
	private int resizeWidth;
	private int resizeHeight;
	
	
	public HOGFeatures(int blockWidth, int blockHeigth, int resizeWidth,
			int resizeHeight) {
		super();
		this.blockWidth = blockWidth;
		this.blockHeigth = blockHeigth;
		this.resizeWidth = resizeWidth;
		this.resizeHeight = resizeHeight;
	}


	@Override
	protected double[] extractFeature(Image candidate) {
		
		if(candidate.getMatrixRepresentation() == null)
			throw new IllegalArgumentException("The image matrix representation it is necessary");
		
		if(candidate.getMatrixRepresentation().channels() > 2)
			candidate = OpenCvCaller.getInstance().convertToGrayScale(candidate);
		
		
		candidate = OpenCvCaller.getInstance().resize(candidate, resizeWidth, resizeHeight);
		
		return  OpenCvCaller.getInstance().computeHOGFeatures(candidate, blockWidth, blockHeigth);
		
	}

}
